package com.quectel.util.aspect.log;

import com.quectel.util.aspect.log.annotation.Log;
import lombok.extern.slf4j.Slf4j;
import org.aopalliance.aop.Advice;
import org.springframework.aop.Pointcut;
import org.springframework.aop.support.AbstractPointcutAdvisor;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;

/**
 * 定义切点和方法拦截器的绑定
 *
 * @author caolu
 * @email louis.cao@quectel.com
 * @date 2023-11-28 14:17:00
 */
@Slf4j
public class LogPointCutAdvisor extends AbstractPointcutAdvisor {
    private static final Pointcut POINTCUT = new AnnotationMatchingPointcut(null, Log.class);

    private LogMethodInterceptor logMethodInterceptor;

    public LogPointCutAdvisor(LogMethodInterceptor logMethodInterceptor) {
        this.logMethodInterceptor = logMethodInterceptor;
    }

    @Override
    public Pointcut getPointcut() {
        return POINTCUT;
    }

    @Override
    public Advice getAdvice() {
        return this.logMethodInterceptor;
    }
}
